package com.ngc.mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ngc.mall.domain.MemberBenefitDomain;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MemberBenefitMapper extends BaseMapper<MemberBenefitDomain> {

    @Insert({"<script>",
            "insert into level_benefit(level_id,benefit_id) values",
            "<foreach collection='benefitIdList' item='item'  separator=',' >",
            "(#{id},#{item})",
            "</foreach>",
            "</script>"})
    Boolean relateBenefitByMemberLevelId(@Param("id") Long id, @Param("benefitIdList") List<Long> benefitIdList);


    @Select({"select  b.* from member_benefit b where b.id in (select benefit_id from level_benefit where level_id =#{id});"})
    List<MemberBenefitDomain> getMemberBenefitListByLevelId(Long id);

    @Delete({"delete from level_benefit where level_id=#{id}"})
    Boolean unRelateMemberBenefit(Long id);
}
